// pages/assess/assess.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    typeArr:[{
 typename: '商品评价',
 stars: [0, 1, 2, 3, 4],
 normalSrc: '../images/kongxing.png',
 selectedSrc: '../images/xingxing.png',
 halfSrc: '../images/bangxing.png',
 key: 0
},{
   typename: '送货速度',
   stars: [0, 1, 2, 3, 4],
   normalSrc: '../images/kongxing.png',
   selectedSrc: '../images/xingxing.png',
   halfSrc: '../images/bangxing.png',
   key: 0
},{
   typename: '快递包装',
   stars: [0, 1, 2, 3, 4],
   normalSrc: '../images/kongxing.png',
   selectedSrc: '../images/xingxing.png',
   halfSrc: '../images/bangxing.png',
   key: 0
}],

},
 //点击左边,半颗星
 selectLeft: function (e) {
  var that = this;
  var key = e.currentTarget.dataset.key;
  var liindex = e.currentTarget.dataset.index;//获取到点击的第几列
  var count = key
  var childkey = "typeArr[" + liindex + "].key"
  if (that.data.typeArr[liindex].key == 0.5 && e.currentTarget.dataset.key == 0.5) {
    //只有一颗星的时候,再次点击,变为0颗
    that.setData({
      [childkey]: 0
    })
  }else{
    that.setData({
      [childkey]: key
    })
  }
},
//点击右边,整颗星
selectRight: function (e) {
  var key = e.currentTarget.dataset.key;
  var liindex = e.currentTarget.dataset.index;//获取到点击的第几列
  var count = key
  var childkey = "typeArr[" + liindex + "].key"
  this.setData({
    [childkey]: key
  })
},


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  //改变Information
  changeInformation:function(e){
    var information = e.detail.value;
    this.setData({
      information
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})